package rowan.application.quickaccess.tabs;

import rowan.application.quickaccess.ExtrasPage;
import rowan.application.quickaccess.ImageAdapter;
import rowan.application.quickaccess.R;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.AdapterView.OnItemClickListener;


/**
 * The Quick Links Activity
 * 
 * 	Displays buttons to Rowan Quick Access, Blackboard, and Rowan.edu
 * 
 * 	- Features to add
 * 		Link to Rowan After Hours
 * 		Maybe build a WebView instead of using Web Browser
 * 		Tips/Tricks?
 * 		Redesign possibily 
 * 
 * @author Tom
 *
 */
public class QuickLinks extends Activity  {
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.quickaccess);
    
        
        
        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ImageAdapter(this));
        
        gridview.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
//                Toast.makeText(QuickLinks.this, "" + position, Toast.LENGTH_SHORT).show();
            	Intent intent = null;
            	if (position == 0) // rowan self service
            		intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://adminweb2.rowan.edu:44380/PROD/twbkwbis.P_WWWLogin"));
            	else if (position == 1)
            		intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://webct3.rowan.edu/webct/entryPageIns.dowebct"));
            	else if (position == 2)
            		intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://rowan.edu"));
            	else if (position ==3)
            		intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://rowan.edu/afterhours"));
            	else if (position == 4)
            		intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.rowansup.com/"));
            	else if (position == 5)
            		intent = new Intent(QuickLinks.this, ExtrasPage.class);
            	
            	startActivity(intent);
            }
        });
        
       
        
/*
        ///////// SELF SERVICE ////////
        Button selfserve = (Button)findViewById(R.id.selfservice);
        selfserve.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://adminweb2.rowan.edu:44380/PROD/twbkwbis.P_WWWLogin"));
                startActivity(intent);
        	}
        }); 
        ///////////////////
        
        
        /////////// BLACK BOARD ///////
        Button blackboard = (Button)findViewById(R.id.blackboard);
        blackboard.setOnClickListener(this);
        blackboard.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://webct3.rowan.edu/webct/entryPageIns.dowebct"));
        		startActivity(intent);
        		
        	}
        }); 
        //////////////////////
        
        
        ////////// Rowan.edu //////////
        Button homesite = (Button)findViewById(R.id.homesite);
        homesite.setOnClickListener(new OnClickListener() {
        	public void onClick(View v) {
        		Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://rowan.edu"));
                startActivity(intent);
        	}
        }); 
        /////////////////////////////////////
        
        
        //  MAIL SERVER SETTINGS
        TextView setting = (TextView)findViewById(R.id.incoming);
        setting.setOnClickListener(this);
        
        setting = (TextView)findViewById(R.id.outgoing);
        setting.setOnClickListener(this);
        setting.setText(setting.getText());
        */
    }
    
    /*
	@Override
	public void onClick(View v) {
		if (v == findViewById(R.id.incoming))
		{
			LinearLayout layout = new LinearLayout(this);
			layout.setOrientation(LinearLayout.VERTICAL);
			
			TextView settings = new TextView(this);
			settings.setText("-USERNAME \n(username)@students.rowan.edu\n" +
								"\n-PASSWORD \n(your password)\n" +
								"\n-IMAP \nimap.gmail.com\n" +
								"\n-PORT \n933\n" +
								"\n-SECURITY TYPE \nSSL (Accept all certificates)\n");
			settings.setPadding(20, 20, 20, 20);
			layout.addView(settings);
			
			Dialog dialog = new Dialog(this);
			dialog.setContentView(layout);
			dialog.setTitle("Incoming Server Details");
			dialog.show();
		}
		
		if (v == findViewById(R.id.outgoing))
		{
			LinearLayout layout = new LinearLayout(this);
			layout.setOrientation(LinearLayout.VERTICAL);
			
			TextView settings = new TextView(this);
			settings.setText("-SMTP SERVER \nsmtp.gmail.com\n" +
								"\n-PORT \n465\n" +
								"\n-SECURITY TYPE \nSSL (Accept all certificates)\n" +
								"\n-USERNAME \n(username)@students.rowan.edu\n" +
								"\n-PASSWORD\n(Your password)\n");
			settings.setPadding(20, 20, 20, 20);
			layout.addView(settings);
			
			Dialog dialog = new Dialog(this);
			dialog.setContentView(layout);
			
			
			
			dialog.setTitle("Outgoing Server Details");
			dialog.show();
		}
		
	} */
}